package queue.class1;

/**
 * https://leetcode.cn/problems/implement-stack-using-queues/description/
 * 用队列实现栈
 */
public class Code02_MyStack {
    public static void main(String[] args) {

    }

    private static class MyStack {
        int[] arr;
        int l, r;

        public MyStack() {
            arr = new int[100];
            l = r = 0;
        }

        public void push(int x) {
            arr[r++] = x;
        }

        public int pop() {
            return arr[--r];
        }

        public int top() {
            return arr[r - 1];
        }

        public boolean empty() {
            return l == r;
        }
    }
}
